package com.star.common.orm.entity;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * 分页数据对象
 *
 * @param <T>
 * @author zhouhengzhe
 */
public class Page<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("总记录数")
    private final long total;

    @ApiModelProperty("列表数据")
    private List<T> records = Collections.emptyList();

    public Page(List<T> records, long total) {
        this.records = records;
        this.total = total;
    }

    public static <T> Page<T> succeed(List<T> records, long total) {
        return new Page(records, total);
    }

    public static <T> Page<T> empty() {
        return new Page(Collections.emptyList(), 0);
    }

    public long getTotal() {
        return this.total;
    }

    public List<T> getRecords() {
        return this.records;
    }
}